home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5620 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: colossus.holonet.net!russell
  2. From: russell@news.mdli.com (Russell Blackadar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: dynamic memory allocation
  5. Date: 1 Feb 1996 22:40:26 GMT
  6. Organization: HoloNet National Internet Access System: 510-704-1058/modem
  7. Message-ID: <4erfgq$2n2@colossus.holonet.net>
  8. References: <310ABD89.5537@gnomic.stanford.edu> <DM0G35.AKr@news.arco.com> <4er1tt$jnm@rolaids.frco.com>
  9. NNTP-Posting-Host: jubal.mdli.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Jim Adam (Jadam@tcmail.frco.com) wrote:
  13.  
  14. : Actually, I think it has to be:
  15.  
  16. :   void *& p   // "POINTER REFERENCE"
  17. ...
  18.  
  19. : It's weird, but the operators appear in opposite order
  20. : of the way you would normally pronounce them....
  21.  
  22. It's not really weird.  It's an example of a general rule in
  23. C declarations -- to find out the type, start at the variable
  24. name, p in this case, and say "p is ..." reading outward as
  25. you follow operator precedence and associativity rules.  Since
  26. & and * have the same precedence and associate right-to-left,
  27. the statement above is read:
  28.  
  29.   "p is a reference to pointer to void"
  30.  
  31. Remembering this rule can get you through even the most
  32. complex declarations, e.g. X &(* a[5][10])(int); 
  33.  
  34.   "a is a 5-element array of 10-element arrays of pointer
  35.   to function taking int and returning reference to X"
  36.  
  37. There's more about this in the c.l.c FAQ.
  38. --
  39. Russell Blackadar,   russell@mdli.com
  40.